<?php
/**
 * Created by Command.
 * User: Vito
 */

declare (strict_types = 1);

namespace app\model;

use think\db\Query;

class Building extends BaseModel
{
    public function housing(){

        return $this->belongsTo('housing', 'housing_id')->bind([
            'housing_name'=>'name',
        ]);
    }
    /**
     * @Description: 获取楼房号
     * @author: xiayu <cb1071403016@126.com>
     * @Date: 2022-11-21 17:29:51
     * @version: 1.0.0
     * @return [type]
     */
    public static function getBuildingClient()
    {
        $res = self::field('id,name,building_number')->select();
        return $res;
    }
    /**
     * 搜索
     * @param Query $query
     * @param $value
     * @return Query
     */
    public function searchIndexAttr(Query $query, $value)
    {   
        return $query->where('name|id', 'like', '%' . $value . '%');
    }
    /**
     * @Description:获取楼房
     * @author: xiayu <cb1071403016@126.com>
     * @param [type] $where
     * @Date: 2022-11-21 17:29:48
     * @version: 1.0.0
     * @return [type]
     */
    public static function getBuilding($where){
        return self::where($where)->find();
    }
    
}
